#pragma once
#include <iostream>
#include <vector>

namespace bit
{
    template<size_t N>
    class bit_set
    {
    public:
        bit_set()
        {
            _bs.resize(N/32 + 1);
        }
        //把对应的位变为1
        void set(size_t x)
        {
            int i = x / 32;      
            int j = x % 32;
            _bs[i] |= (1 << j);
        }

        //把对应的位变为0
        void reset(size_t x)
        {
            int i = x / 32;      
            int j = x % 32;
            _bs[i] &= (~(1 << j));
        }
        //检查是否存在
        bool test(size_t x)
        {
            int i = x / 32;      
            int j = x % 32;
            return _bs[i] & (1 << j);
        }
    private:
        std::vector<int> _bs;
    };
}
